<!DOCTYPE html>
<html>

<head>
    <include file="public@head" title="联系我们" keywords="{$site_info.site_seo_keywords}"
             description="{$site_info.site_seo_description}"/>
</head>

<body>

<include file="public@header"/>

<div class="page-header">
    <div class="layui-container">
        <div class="page-header-area">
            <h1 class="page-header-title">Contact Us</h1>
        </div>
    </div>
</div>
<div class="layui-container">
    <hr class="bg-transparent"/>
    <p class="layui-breadcrumb">
        <a href="/">首页</a>
        <a><cite>联系我们</cite></a>
    </p>
    <hr class="bg-transparent"/>
</div>
<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">留言</div>
                <div class="layui-card-body">
                    <form action="/contact" method="post" class="layui-form">
                        <div class="layui-form-item layui-col-space10">
                            <div class="layui-col-md4">
                                <input type="text" class="layui-input" name="name" lay-verify="required|name" lay-verType="tips"
                                       placeholder="联系人">
                            </div>
                            <div class="layui-col-md4">
                                <input type="text" class="layui-input" name="email" lay-verify="required|email"
                                       lay-verType="tips"
                                       placeholder="邮箱">
                            </div>
                            <div class="layui-col-md4">
                                <input type="text" class="layui-input" name="mobile" lay-verify="phone"
                                       lay-verType="tips"
                                       placeholder="手机号">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <textarea class="layui-textarea" name="content" lay-verify="required" placeholder="您可以输入简短的描述"></textarea>
                            <div class="layui-form-mid layui-word-aux"><span id="text-count">300</span>/300</div>
                        </div>
                        <div class="layui-form-item">
                            <button type="submit" class="layui-btn" lay-submit lay-filter="submit">提交</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">联系信息</div>
                <div class="layui-card-body">
                    <ul class="layui-timeline">
                        <notempty name="site_info.address">
                            <li class="layui-timeline-item">
                                <i class="layui-icon layui-timeline-axis"></i>
                                <div class="layui-timeline-content layui-text">
                                    <div class="layui-timeline-title">联系地址：{$site_info.address}</div>
                                </div>
                            </li>
                        </notempty>
                        <notempty name="site_info.phone">
                            <li class="layui-timeline-item">
                                <i class="layui-icon layui-timeline-axis"></i>
                                <div class="layui-timeline-content layui-text">
                                    <div class="layui-timeline-title">联系电话：<a href="tel://{$site_info.phone}">{$site_info.phone}</a></div>
                                </div>
                            </li>
                        </notempty>
                        <notempty name="site_info.worktime">
                            <li class="layui-timeline-item">
                                <i class="layui-icon layui-timeline-axis"></i>
                                <div class="layui-timeline-content layui-text">
                                    <div class="layui-timeline-title">工作时间：{$site_info.worktime}</div>
                                </div>
                            </li>
                        </notempty>
                        <notempty name="site_info.site_email">
                            <li class="layui-timeline-item">
                                <i class="layui-icon layui-timeline-axis"></i>
                                <div class="layui-timeline-content layui-text">
                                    <div class="layui-timeline-title">电子邮箱：<a class="" href="mailto:{$site_info.site_email}">{$site_info.site_email}</a></div>
                                </div>
                            </li>
                        </notempty>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
<include file="public@footer"/>
<script>
    layui.use(['layer', 'jquery', 'form','element'], function () {
        var layer = layui.layer,
            $ = layui.jquery,
            form = layui.form,element = layui.element;

        $("textarea[name='content']").on("input propertychange", function () {
            let $this = $(this),
                _val = $this.val();

            if (_val.length > 300) {
                $this.val(_val.substring(0, 300));
            }
            let count = 300 - $this.val().length;
            $("#text-count").text(count);
        });

        form.verify({
            name: function(value, item){
                if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
                    return '用户名不能有特殊字符';
                }
                if(/(^\_)|(\__)|(\_+$)/.test(value)){
                    return '用户名首尾不能出现下划线\'_\'';
                }
                if(/^\d+\d+\d$/.test(value)){
                    return '用户名不能全为数字';
                }
            }
        });

        form.on('submit(submit)', function (data) {
            layer.load();
            $.post(data.form.action, data.field, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg, {time: 1000}, function () {
                        window.location.reload();
                    });
                }
                else {
                    layer.msg(res.msg, {}, function () {
                        layer.closeAll();
                    });
                }
            });
            return false;
        });
    });
</script>
</body>

</html>
